function CheckUser(){
	var url = 'Member/index';
	var userInfo = api_request(url, 'GET'); //请求会员

	return  userInfo;
}

function getInfo(){
	var url = 'cms/site';
	var webInfo = api_request(url, 'GET');
	if(webInfo){
		document.title=webInfo.data.title;
	}
	 

	 var member = CheckUser();
	 if(member.data.data){
			var data=member.data.data; 
	 }


	
	 headpic = (data.headpic != '') ? data.headpic : 'images/bag-imgB.jpg'
	 $('#headpic').attr('src', headpic);
	 $('#username').append(data.usermobile);
	 $('#up_integral').append(data.up_integral);
	 $('#qcore').append(data.qcore);
	 $('#score').append(data.score);
	 if(data.count){
			$('#NewUser').append(data.count.NewUser);
			$('#activateUser').append(data.count.activate); 
		 }else{
			 $('#NewUser').append('0');
			 $('#activateUser').append('0'); 
		 }
	     $('#buyquota').append(data.buyquota);
	 
        //排单信息
        var Poolurl = 'Scheduling/Snap_lines';
        var PoolInfo = api_request(Poolurl, 'GET'); //请求接口
        var html = '';
		if(data.gid !=1 && data.status !=0){
			if (PoolInfo.code == 1) {
			    var data = PoolInfo.data;
			    if (data.status == 1) {
			        html = " <div class='jq22-credit-bg'> <h2>" + data.pname + "</h2><h3>" + data.sauota + "</h3><p style='font-size: 15px;'><span id='timeTit'></span>  <span id='_d'></span><span id='_h'></span><span id='_m'></span><span id='_s'></span></p><button class='button'onclick='Snap_lines(" + data.id + ");' id='button'>抢购额度</button> </div> "
			        $('#pool').append(html);
			          countTime();
				   function countTime() {
					  
				   	       var begDate = new Date(data.begin_time);
				   	       //设置结束时间
				   	       var endDate = new Date(data.end_time);
				   	       var end = endDate.getTime(); // 结束秒数
				   	       var beg = begDate.getTime(); // 开始秒数
				   	      //获取当前时间
				   	      var date = new Date();
				   	      // 当前时间秒数
				   	      var now = date.getTime();
				   	      //时间差
				   	      var leftTime = end - now; // 结束秒数 - 现在秒数
				   	      var begTime = beg - now;  // 开始秒数 - 现在秒数
				   	      //定义变量 d,h,m,s保存倒计时的时间
				   	      var d, h, m, s;
				   	      var timeTit = document.getElementById('timeTit'); // 时间前文档
				   	      if(begTime>=0){ //  如果开始时间大于等于0 的时候 执行
				   	        timeTit.innerHTML = "距离排单开始"
				   	        d = Math.floor(begTime / 1000 / 60 / 60 / 24);
				   	        h = Math.floor(begTime / 1000 / 60 / 60 % 24);
				   	        m = Math.floor(begTime / 1000 / 60 % 60);
				   	        s = Math.floor(begTime / 1000 % 60);
				   	        document.getElementById("_d").innerHTML = d + "天";
				   	        document.getElementById("_h").innerHTML = h + "时";
				   	        document.getElementById("_m").innerHTML = m + "分";
				   	        document.getElementById("_s").innerHTML = s + "秒";
							$("#pool").attr("style","display:none;");
				   	      }else if (leftTime >= 0) { // 当结束时间大于等于0 的时候执行这里
				   	        timeTit.innerHTML = '距离排单结束'
				   	        d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
				   	        h = Math.floor(leftTime / 1000 / 60 / 60 % 24);
				   	        m = Math.floor(leftTime / 1000 / 60 % 60);
				   	        s = Math.floor(leftTime / 1000 % 60);
				   	        //将倒计时赋值到div中
				   	        document.getElementById("_d").innerHTML = d + "天";
				   	        document.getElementById("_h").innerHTML = h + "时";
				   	        document.getElementById("_m").innerHTML = m + "分";
				   	        document.getElementById("_s").innerHTML = s + "秒";
								$("#pool").attr("style","display:block;");
				   	        //递归每秒调用countTime方法，显示动态时间效果
				   	 
				   	      } else {  // 结束的时候执行这里
				   	        timeTit.innerHTML = "活动已经结束"
				   	        document.getElementById("_d").innerHTML = 0 + "天";
				   	        document.getElementById("_h").innerHTML = 0 + "时";
				   	        document.getElementById("_m").innerHTML = 0 + "分";
				   	        document.getElementById("_s").innerHTML = 0 + "秒";
				   	        clearTimeout(countTime); //  结束的时候清除定时器
								$("#pool").attr("style","display:none;");
							 	ModPool(data.id);
				   	        return;  // 并停止这个函数
				   	      }
				   	      setTimeout(countTime, 1000); // 每一秒执行一次这个函数
				   	    }
			    }
			
			}
		}
       
		}
		
		function ModPool(id){
			var ModPoolurl = 'Scheduling/ModPool?id='+id;
			var ModPoolInfo = api_request(ModPoolurl, 'GET'); //请求接口
			if(ModPoolInfo.code==1){
				layer.open({
				    content: ModPoolInfo.data
				    , skin: 'msg'
				    , time: 2//2秒后自动关闭
				    , end: function () {
				     location.reload();
				    }
				});
			}
		}
		function SignIn() {
		    layer.open({
		        content: '确定退出吗？'
		        , btn: ['退出', '取消']
		        , skin: 'footer'
		        , yes: function (index) {
		            var url = 'Member/logout';
		            var logout = api_request(url, 'GET')
			
		        }
		    });
		}
		function Snap_lines(id){
		
			  layer.open({
			    title: [
			      '输入购买金额',
			      'background-color: #ff0000; color:#fff;'
			    ]
			    ,content: "<input type='number' required  min=10000 name='quota'  id='quota' placeholder='购买金额'> <label id='error' class='error cc_cursor'style='display: none;'></label><button class='button' onclick='addPool("+id+");'><i class='fa fa-send'></i>提交</button>"
			  });
		}
		  
		function addPool(id){
			
			error = document.getElementById("error");
			var quota=$("#quota").val();
			if (quota == "") {
				$("#error").attr("style","display:block;");
				 error.innerHTML = "请输入金额";//改变内容
			    return false;
			}
			var parm={
				pid:id,
				quota:quota,
			}
			var Buyurl = 'Scheduling/Buy_single';
			var BuyInfo = api_request(Buyurl, 'POST',parm); //请求接口
			if(BuyInfo.code==6){
				$("#error").attr("style","display:block;");
				 error.innerHTML = BuyInfo.data;//改变内容
			}
			if(BuyInfo.code==1){
				layer.open({
				    content: BuyInfo.data
				    , skin: 'msg'
				    , time: 2//2秒后自动关闭
				    , end: function () {
						   location.reload();
				    }
				});
			}
		}
		
	function subgo(url,status){
		var User=CheckUser();
	
	 if(status==1){
	   location.href =url+'.html';
	 }else{
		if( User.data.data.gid ==1){
	     layer.open({
	         content: '账号未激活或者被冻结!'
	         , skin: 'msg'
	         , time: 2 //2秒后自动关闭
	     });
		}else{
			  location.href =url+'.html';
			
		}
	}
	}